home *** CD-ROM | disk | FTP | other *** search
/ PC Player 2004 May / pc player 2004-05.iso / Demos / FarCry / Data1.cab / _527DB7AD394A4D98B1B7E8F75CC5E9F6 < prev    next >
Encoding:
Text File  |  2004-01-06  |  2.1 KB  |  84 lines

  1. // ===============================================================
  2. // Vertex Program: Indoor Water
  3. // Description: used in indoor refractive water
  4. // Last Update: 18/11/2003
  5. // Coder: Tiago Sousa
  6. // ===============================================================
  7.  
  8. #include "../CGVPMacro.csi"
  9.  
  10. VertAttributes { POSITION_3 }
  11.  
  12. // setup vertex components
  13. MainInput
  14. {
  15.   // common model view matrix
  16.   uniform float4x4 ModelViewProj,
  17.   uniform float4   CameraPos,      
  18.   uniform float4   TexGenRipple0,
  19.   uniform float4   TexGenRipple1,
  20.   uniform float4   TexShiftRipple,
  21.   uniform float4   TexDetailScale,     
  22.   uniform float4   ScreenSize
  23. }
  24.  
  25. Projected
  26.  
  27. DeclarationsScript
  28. {
  29.   // vertex input
  30.   IN_P
  31.   // vertex output
  32.   OUT_T0_T1_C0
  33. }
  34.  
  35. // output vertex position
  36. PositionScript = PosCommon
  37.  
  38. CoreScript
  39. {    
  40.   float4 vHPos = mul(ModelViewProj, vPos);     
  41.  
  42. #ifdef D3D
  43.   #ifdef PROJECTEDENVBUMP
  44.   // optimized perspective correct projection
  45.   OUT.Tex1.xz = (vHPos.xz  + vHPos.w)*0.5;    
  46.   OUT.Tex1.y =  (-vHPos.y  + vHPos.w)*0.5;      
  47.   OUT.Tex1.w   = vHPos.w;      
  48.   #endif
  49.   #ifdef OTHER
  50.   // have to use per-vertex projection..
  51.   vHPos.y = -vHPos.y;
  52.     OUT.Tex1.xy = ((vHPos.xy/vHPos.w) + 1)*0.5;          
  53.   #endif
  54. #endif
  55.  
  56. #ifdef OPENGL        
  57.   #ifdef PROJECTEDENVBUMP
  58.   // optimized perspective correct projection
  59.   OUT.Tex1.xz = (vHPos.xz  + vHPos.w)*0.5*ScreenSize.x;    
  60.   OUT.Tex1.y =  (vHPos.y  + vHPos.w)*0.5*ScreenSize.y;      
  61.   OUT.Tex1.w   = vHPos.w;      
  62.   #endif
  63.   #ifdef OTHER
  64.     // have to use per-vertex projection..
  65.     OUT.Tex1.xy = ((vHPos.xy/vHPos.w) + 1)*0.5*ScreenSize.xy;          
  66.     #endif
  67. #endif
  68.         
  69.   // output texture coordinates  
  70.   float2 vTex;
  71.   vTex.x = dot(vPos, TexGenRipple0);
  72.   vTex.y = dot(vPos, TexGenRipple1);
  73.   vTex.xy= (vTex.xy+(TexDetailScale.w*TexShiftRipple.zw))*TexDetailScale.xy;
  74.   OUT.Tex0.xy = vTex.xy;
  75.             
  76.   // output color and fresnel term hack  
  77.   //float3 eyeVec = normalize(CameraPos.xyz - vPos.xyz);  
  78.   //float3 fNormal=float3(0,0,1);
  79.   //float fDot= abs(dot(eyeVec, fNormal));      
  80.   OUT.Color.w =1; //fDot*2.0*(1-0.05*vHPos.w);
  81.    
  82.   return OUT;
  83. }
  84.